package cn.lidar.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.multipart.commons.CommonsMultipartResolver;

@Configuration
public class ApplicationConfig {
    @Bean(name = "multipartResolver")
    CommonsMultipartResolver commonsMultipartResolver() {
        CommonsMultipartResolver cmr = new CommonsMultipartResolver();
        cmr.setDefaultEncoding("utf-8");
        // 指定所上传文件的总大小，maxUploadSize限制不是针对单个文件，而是所有文件的容量之和
        cmr.setMaxUploadSize(10 * 1048576);    // 单位 b，1048576 b = 1Mb
        return cmr;
    }
}
